package com.minhua.jijiehao2.utils

import android.text.TextUtils
import android.util.Log
import com.minhua.jijiehao2.constants.DefineKey
import com.minhua.jijiehao2.http.ApiClient
import com.minhua.jijiehao2.http.BaseSubscriber
import com.minhua.jijiehao2.http.HttpController
import com.minhua.jijiehao2.http.ParamsMap

/**
 * @author moo
 * @date 2017/12/28.
 * @describe
 */

object CountUtils {
    /**
     * 渠道详情页
     */
    val PLAT_DETAIL = "platDetail"
    /**
     * 立即申请
     */
    val PLAT_REGISTER = "platRegister"
    /**
     * 信用卡申请
     */
    val CARD = "card"

    /**
     * 分类图标
     */
    val SORTPIC = "sortPic"

    /**
     *贷款选项卡
     */
    val LOANSTABS = "loansTabs"

    /**
     *信用卡选项卡
     */
    val CREDITTABS = "creditTabs"

    fun recodeDetail(positionMark: String, id: String) {
        val userId = SPUtils.get(DefineKey.USER_ID, "") as String
        if (TextUtils.isEmpty(userId)) {
            return
        }
        val map = ParamsMap()
        map.put("userId", userId)
        map.put("positionMark", positionMark)
        map.put("flag", id)
        HttpController<Any>().doHttp(
                ApiClient.getInstance().api.recode(map.toRequestBody()),
                object : BaseSubscriber<Any>() {

                },
                false
        )
        Log.e("count", positionMark)
    }

    fun recodeChannel(id: String, pCode: String) {
        val map = ParamsMap()
        map.put("id", id)
        map.put("pCode", pCode)
        HttpController<Any>().doHttp(
                ApiClient.getInstance().api.channelRecode(map.toRequestBody()),
                object : BaseSubscriber<Any>() {

                },
                false
        )
    }

    fun deitailClick(procId: Long) {
        val map = ParamsMap()
        map.put("userId", SPUtils.get(DefineKey.USER_ID, ""))
        map.put("procId", procId)
        HttpController<Any>().doHttp(
                ApiClient.getInstance().api.getClickNum(map.toRequestBody()),
                object : BaseSubscriber<Any>() {

                },
                false
        )
    }
}
